package com.sky.controller.user;

import com.sky.context.BaseContext;
import com.sky.dto.ViolationRecordPageQueryDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.ViolationRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("userViolationController")
@RequestMapping("/user/violation")
@Api(tags = "违法记录相关接口")
@Slf4j
public class ViolationRecordController {
    @Autowired
    private ViolationRecordService violationRecordService;
    /**
     * 个人分页查询
     * @param pageQuery
     * @return
     */
    @RequiresPermissions("普通用户")
    @GetMapping("/page")
    @ApiOperation("个人违法记录分页查询")
    public Result<PageResult> page(ViolationRecordPageQueryDTO pageQuery) {
        pageQuery.setUserId(BaseContext.getCurrentId());
        PageResult pageResult = violationRecordService.mypageQuery(pageQuery);
        return Result.success(pageResult);
    }

}
